Testing cell renumbering:
In[7]:=
$Line=1234
Out[1234]=
1234
In[1235]:=
Range[10000]//Short
Out[1235]//Short=
{1,2,3,4,5,6,7,8,9,10,11,9978,9990,9991,9992,9993,9994,9995,9996,9997,9998,9999,10000}
Start with an image:
In[1]:=
img=
;
Convert to grayscale and apply dithering using the resource function FloydSteinbergDithering:
In[2]:=
dithered=
[◼]
FloydSteinbergDithering
[ColorConvert[img,"Grayscale"],2]
Out[2]=
Extract the set of coordinates corresponding to dark pixels with
PixelValuePositions
and add some slight noise:
In[3]:=
pts=PixelValuePositions[dithered,0];​​noisy=RandomReal[{-.15,.15},Dimensions[pts]]+pts
Out[4]=
{{0.983242,97.9591},{3.14381,98.0129},{4.88179,98.1228},{7.04649,97.9469},{9.14214,98.0841},{11.0581,97.8632},{12.9178,98.1276},
⋯3983⋯
,{117.126,1.0599},{119.981,1.0192},{122.889,1.02882},{133.011,1.14902},{141.005,1.08078},{146.109,0.946914}}
Full expression not available
(
original memory size:
65.6 kB)
Preview the points:
In[5]:=
Graphics[Point[noisy]]
Out[5]=
Use
FindShortestTour
to generate a single line that visits very point:
In[6]:=
tour=Last[FindShortestTour[noisy]]
Out[6]=
{1,2,3,4,5,79,126,80,6,7,8,81,133,82,9,10,83,11,12,13,14,85,138,192,259,193,194,139,86,15,16,17,87,140,195,196,197,141,88,18,19,20,89,142,198,199,262,263,321,380,440,439,438,379,349,296,261,320,378,437,490,547,
⋯3873⋯
,938,867,833,768,735,673,705,734,797,796,733,671,672,645,591,538,569,623,646,706,736,737,674,647,592,540,539,483,430,374,318,257,244,184,130,78,77,129,188,243,287,340,339,398,429,482,481,454,537,590,622,568,511,453,397,338,286,242,183,128,76,1}
Full expression not available
(
original memory size:
32.9 kB)
These numbers represent the order that points should be visited.
GraphicsComplex
is a convenient way to represent graphics primitives using a set of points and indices.
Create a
Line
that passes through the points in order:
In[7]:=
Graphics[GraphicsComplex[noisy,Line[tour]]]
Out[7]=
Use the original image to add some color:
In[8]:=
Graphics[GraphicsComplex[noisy,Line[tour,VertexColorsDarker[RGBColor/@PixelValue[img,pts[[tour]]]]]]]
Out[8]=

Adding More Detail 
(2)
 

To add detail to the maze, all that's needed is to resize the image to a higher resolution. Similarly, the detail can be decreased by lowering the image resolution.
Double the resolution of the original image with
ImageResize
:
In[1]:=
large=ImageResize
,Scaled[2]
Out[1]=
Repeat the steps from above:
In[2]:=
dithered=
[◼]
FloydSteinbergDithering
[ColorConvert[large,"Grayscale"],2];​​pts=PixelValuePositions[dithered,0];​​noisy=RandomReal[{-.15,.15},Dimensions[pts]]+pts;​​tour=Last[FindShortestTour[noisy]];​​Graphics[GraphicsComplex[noisy,Line[tour,VertexColorsDarker[RGBColor/@PixelValue[large,pts[[tour]]]]]]]
Out[6]=

Generalization 
(6)
 
